//
//  AppDelegate.swift
//  CMDB
//
//  Created by 王磊 on 17/4/5.
//  Copyright © 2017年 CMDB. All rights reserved.
//

import UIKit

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
    
    var window: UIWindow?
    
    var defaultViewController : UIViewController? {
        
        let account                = CMDBApplicationManager.getInstance.queryAccount()
        
        let controller             = CMDBLoginViewController()
        
        if (account?.token) != nil {
            
            // 设置全局颜色
            UITabBar.appearance().tintColor = UIColor.orangeColor()
            
            return UIStoryboard(name: "Main", bundle: nil).instantiateInitialViewController()
           
        }else{

            
             return CustomNavigationControllerViewController(rootViewController: controller, hideNavBar: true)
        }
    }
    
    func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
        
        
        setupKeyBoard()
        
        window                     = UIWindow(frame: UIScreen.mainScreen().bounds)
        
        // 设置全局颜色
        UITabBar.appearance().tintColor = UIColor.Hex(0xff6d00)
        
        window?.rootViewController = UIStoryboard(name: "Main", bundle: nil).instantiateInitialViewController()
       
        window?.rootViewController = defaultViewController
        
        window?.makeKeyAndVisible()
        
        return true
    }
}


extension AppDelegate {
    
    func setupKeyBoard(){
        
        IQKeyboardManager.sharedManager().enable = true
        
        IQKeyboardManager.sharedManager().shouldResignOnTouchOutside = true

    }
    
    }


